#include "easymqconsumer.h"
#include "util.h"
#include "easylog.h"

using namespace util;

CEasyMqConsumer::CEasyMqConsumer() {

}

CEasyMqConsumer::~CEasyMqConsumer() {

}

void CEasyMqConsumer::load(std::string strName, MqClient::CMqConsumer::MQ_MSG_CB cb) {
    m_strName = strName;
    host = Settings::getValue(m_strName,"host");
    port = Settings::getValue(m_strName,"port", 5672);
    usr  = Settings::getValue(m_strName,"usr");
    pwd  = Settings::getValue(m_strName,"pwd");
    exc  = Settings::getValue(m_strName,"exc", "");
    type = Settings::getValue(m_strName,"type", "fanout");
    que  = Settings::getValue(m_strName,"que", "");
    bind = Settings::getValue(m_strName,"bind", "");
    _mqSrc = MqClient::CMqConsumer::Create(m_strName, host, port, usr, pwd, exc, type, que, bind, cb);
    Log::debug("mq consumer start --> %s %d %s %s %s", host.c_str(), port, usr.c_str(), pwd.c_str(), que.c_str());
}